package controlGraph;

import java.util.HashMap;

public class StatementFactory {
    public static void main(String [] args) {
            HashMap<String, Integer> labels = new HashMap<String, Integer>();
            Statement first = new DeclarationStatement("int", "x", 3, new ArrayLitExpression(new Expression[] {new LValueInt(1), new LValueInt(2), new LValueInt(3)}));
            Statement decl14 = new DeclarationStatement("int", "a", 0, new LValueInt(2));
            Statement decl15 = new DeclarationStatement("int", "b", 0, UndefinedExpression.getInstance());
            Statement decl16 = new DeclarationStatement("int", "y", 0, UndefinedExpression.getInstance());
            Statement cond17 = new ConditionalGoto("end", new ArithExpr("<", new Variable("b"), new LValueInt(0)));
            Statement cond18 = new ConditionalGoto("end", new ArithExpr(">=", new Variable("y"), new ArrayRef(new Expression[] {new Variable("x"), new Variable("a")})));
            Statement cond19 = new ConditionalGoto("end", new ArithExpr(">", new Variable("b"), new Variable("y")));
            Statement assign20 = new AssignmentStatement(new Variable("a"), new ArrayRef(new Expression[] {new Variable("x"), new Variable("b")}));
            labels.put("end", Statement.getLastNum());
            Statement decl21 = new DeclarationStatement("int", "c", 0, new LValueInt(3));
            
            Statement.doneWithStatements();
            try {
                    Statement.processLabels(labels);
                    first.visitSuccessors(new store(), new ArrayArith());
            } catch(InstantiationException ie) {
                    System.err.println("Bad label: " + ie.getMessage());
            }
            
            System.out.println("The System access in this program is SAFE !!! :) ");
    }
}

//SAMPLE - Works
/*Statement first = new DeclarationStatement("int", "x", 3, new ArrayLitExpression(new Expression[] {new LValueInt(1), new LValueInt(2), new LValueInt(3)}));
Statement decl14 = new DeclarationStatement("int", "a", 0, new LValueInt(0));
Statement decl15 = new DeclarationStatement("int", "b", 0, new LValueInt(1));
Statement decl16 = new DeclarationStatement("int", "c", 0, new LValueInt(2));
Statement decl17 = new DeclarationStatement("int", "d", 0, new LValueInt(4));
Statement decl18 = new DeclarationStatement("int", "temp", 0, new ArrayRef(new Expression[] {new Variable("x"), new Variable("a")}));
Statement assign19 = new AssignmentStatement(new ArrayRef(new Expression[] {new Variable("x"), new Variable("a")}), new ArrayRef(new Expression[] {new Variable("x"), new Variable("b")}));
Statement assign20 = new AssignmentStatement(new ArrayRef(new Expression[] {new Variable("x"), new Variable("b")}), new ArrayRef(new Expression[] {new Variable("x"), new Variable("c")}));
Statement assign21 = new AssignmentStatement(new ArrayRef(new Expression[] {new Variable("x"), new Variable("c")}), new Variable("temp"));
Statement assign22 = new AssignmentStatement(new ArrayRef(new Expression[] {new Variable("x"), new LValueInt(2)}), new Variable("d"));
Statement assign23 = new AssignmentStatement(new ArrayRef(new Expression[] {new Variable("x"), new Variable("a")}), new ArrayRef(new Expression[] {new Variable("x"), new ArrayRef(new Expression[] {new Variable("x"), new Variable("a")})}));
Statement assign24 = new AssignmentStatement(new Variable("a"), new ArrayRef(new Expression[] {new Variable("x"), new Variable("a")}));
*/

